from abc import ABC, abstractmethod
from llmweb import BrowserPool
from typing import Optional, AsyncGenerator
import asyncio
class LLMWebBase(ABC):
    pool: BrowserPool 
    site: str
    wait_timeout: float # 60 seconds
    
    def __init__(self, site: str, pool: BrowserPool, timeout: Optional[float] =  60*1000):
        self.site = site
        self.pool = pool
        self.wait_timeout = timeout
    
    @abstractmethod
    async def generate(self, prompt: str, **kwargs) -> AsyncGenerator[str, None]:
        raise NotImplementedError
    
    def match(self, url: str) -> bool:
        return self.site in url
            
class LoginMixin(ABC):
    @abstractmethod
    async def login(self, **kwargs):
        raise NotImplementedError
    
class PostRunMixin(ABC):
    @abstractmethod
    async def post_run(self, **kwargs):
        raise NotImplementedError
